package com.rc.saas.mini.config;

import com.rc.saas.mini.common.mq.MqConfig;
import com.rc.saas.mini.common.mq.RabbitListenerConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 交换器绑定队列与KEY
 * 动态生成队列
 */
@Configuration
public class QueueConfig {


    //===============以下是验证direct Exchange的队列==========
    @Bean
    public Queue platformApply() {
        return new Queue(MqConfig.platform_apply);
    }

    @Bean
    public Queue paymentRefundOrder() {
        return new Queue(RabbitListenerConstant.PAYMENT_REFUND_ORDER);
    }

    @Bean
    public Binding platformApplyBinding(CustomExchange customExchange) {
        return BindingBuilder.bind(platformApply()).to(customExchange).with(MqConfig.platform_apply).noargs();
    }

    @Bean
    public Binding paymentRefundOrderBinding(CustomExchange customExchange) {
        return BindingBuilder.bind(paymentRefundOrder()).to(customExchange).with(RabbitListenerConstant.PAYMENT_REFUND_ORDER).noargs();
    }


    @Bean
    public Queue appRcOperatorAccountRecord() {
        return new Queue(MqConfig.app_rc_operator_account_record);
    }

    @Bean
    public Binding appRcOperatorAccountRecordBinding(CustomExchange customExchange) {
        return BindingBuilder.bind(appRcOperatorAccountRecord()).to(customExchange).with(MqConfig.app_rc_operator_account_record).noargs();
    }
    //@Bean
    //public Queue open2app_notify_stop_charge_result() {
    //    return new Queue(MqConfig.open2app_notify_stop_charge_result);
    //}
    //
    //@Bean
    //public Binding open2app_notify_stop_charge_resultBinding(CustomExchange customExchange) {
    //    return BindingBuilder.bind(open2app_notify_stop_charge_result()).to(customExchange).with(MqConfig.open2app_notify_stop_charge_result).noargs();
    //}

}
